package Jasper.dao.impl;

import Jasper.dao.IProductDao;
import Jasper.entity.Pro_Class;
import Jasper.entity.Product;
import Jasper.utils.DBManager;

import java.util.List;

/**
 * @ClassName ProductDaoImpl
 * @Author jiangjiajia
 * @JDK-Version 1.8
 * @Date 2021/6/2 9:10 pm
 * @Version 1.0
 * @Description 产品类型的dao层
 **/
public class ProductDaoImpl implements IProductDao {
    /**
     * 分页商品页面的信息
     *
     * @param offset
     * @param num
     * @return
     */

    @Override
    public List<Product> page_product_list(int offset, int num) {
        List<Product> list = DBManager.commonQuery("select * from product where STATUS = 1 limit ?,?;",
                Product.class,
                offset, num);
        return list;
    }

    /**
     * 获取所有产品信息
     *
     * @return
     */
    @Override
    public List<Product> getproductlist() {
        List<Product> list = DBManager.commonQuery("select * from product;",
                Product.class);
        return list;
    }

    @Override
    public List<Product> getproductclasslist() {
        return null;
    }


    /**
     * 商品类别新增
     * @param pro_class
     * @return
     */

    @Override
    public int addPro_Class(Pro_Class pro_class) {
        Integer rSet = DBManager.commonUpdate("insert into class(class_name,class_sort) VALUES (?,?);",
                pro_class.getClass_name(),
                pro_class.getClass_sort());
        return rSet;
    }

    /**
     * 获取商品分类信息
     * @return
     */
    @Override
    public List<Pro_Class> getPro_class() {
        List<Pro_Class> list = DBManager.commonQuery("select * from class;",
                Pro_Class.class);

        return list ;
    }
}
